//---------------------------------------------------------------------------
#ifndef CPopBtnH
#define CPopBtnH
//---------------------------------------------------------------------------
#include <SysUtils.hpp>
#include <Controls.hpp>
#include <Classes.hpp>
#include <Forms.hpp>
#include <ExtCtrls.hpp>
#include <Buttons.hpp>
#include "CtrlStd.h"
//---------------------------------------------------------------------------
class PACKAGE_CTRLSTD CPopupButton : public TCustomControl
{
private:
  TSpeedButton *m_psbDown;
  TSpeedButton *m_psbButton;
  TActionList  *m_paclMenu;
  int           m_nDefaultMenu;
  bool          m_bEnabled;
  AnsiString    m_strCaption;
  TMenuItem    *m_pMenuItem;
  TCustomImageList *m_ImagesList;
  bool          m_bShowMainText;
  bool          m_bShowBtnDown;
  TModalResult  m_ModalResult;

  void __fastcall evOnDownButtonClick( TObject *pSender);
  void __fastcall DrawItemEvent( TObject *pSender, TCanvas *pCanvas, const TRect &Rect, bool bSelected);
  void __fastcall MeasureItemEvent( TObject *pSender, TCanvas *pCanvas, int &nWidth, int &nHeight);

  void __fastcall SetActionList( TActionList *paclMenu);
  void __fastcall SetFont( TFont *pfont);
  void __fastcall SetEnabled( bool bEnabled);
  void __fastcall SetFlat( bool bFlat);
  void __fastcall SetCaption( const AnsiString strCaption);
  void __fastcall SetDefault( int nIndex);
  void __fastcall SetImagesList( TCustomImageList *_ImagesList);
  void __fastcall SetShowMainText( bool _bShowMainText);
  void __fastcall SetShowBtnDown( bool _bShowBtnDown);
  void __fastcall SetFlatBtn( bool _bFlat);

  TFont *__fastcall GetFont( void) const;
  bool __fastcall GetFlat( void) const;
  bool __fastcall GetFlatBtn( void) const;

    void __fastcall CMDialogChar(TWMKey &Message);

protected:
  virtual void __fastcall Notification( TComponent *pComponent, TOperation Operation);
  __property Hint;
  __property ShowHint;

    void __fastcall evOnButtonClick(TObject *Sender);

    BEGIN_MESSAGE_MAP
        VCL_MESSAGE_HANDLER(CM_DIALOGCHAR, TWMKey, CMDialogChar)
    END_MESSAGE_MAP(TCustomControl)

public:
  __fastcall CPopupButton(TComponent* Owner);
__published:
  __property TActionList *ActionList = { read=m_paclMenu, write=SetActionList };
  __property Anchors;
  __property BiDiMode;
  __property AnsiString Caption = { read=m_strCaption, write=SetCaption };
  __property Constraints;
  __property DragCursor;
  __property DragKind;
  __property DragMode;
  __property Enabled = { read=m_bEnabled, write=SetEnabled, default=true };
  __property bool Flat = { read=GetFlat, write=SetFlat, default=false };
  __property Font = { read=GetFont, write=SetFont };
  __property int Default = { read=m_nDefaultMenu, write=SetDefault, default=0 };
  __property Height = { default=25  };
  __property TModalResult ModalResult = { read=m_ModalResult, write=m_ModalResult, default=mrNone };
  __property ParentBiDiMode;
  __property ParentFont;
  __property ParentShowHint;
  __property TabOrder;
  __property TabStop;
  __property Visible;
  __property Width  = { default=100 };
  __property TCustomImageList *Images = { read=m_ImagesList, write=SetImagesList };
  __property bool ShowMainText = { read=m_bShowMainText, write=SetShowMainText, default=true };
  __property bool ShowBtnDown = { read=m_bShowBtnDown, write=SetShowBtnDown, default=true };
  __property bool FlatBtn = { read=GetFlatBtn, write=SetFlatBtn, default=false };

  __property OnDragDrop;
  __property OnDragOver;
  __property OnEndDock;
  __property OnEndDrag;
  __property OnEnter;
  __property OnExit;
  __property OnStartDock;
  __property OnStartDrag;
};
//---------------------------------------------------------------------------
#endif